<template>
  <div class="detail-wraps">
    <swiper :options="swiperOption" ref="mySwiper">
      <template v-for="(item,index) in detail.opus">
          <swiper-slide :key="index">
            <div class="backgroud">
            <img v-lazy="domin+item.img" class="backgroud-img">
            </div>
            <img v-lazy="domin+item.img" class="main-img">
            <h3 class="center title">《呵呵》</h3>
            <div class="center">{{item.flat_size}}</div>
            <div class="center">{{item.age | formatDate('yyyy')}}·作</div>
            <div>款式：{{item.inscribe}}</div>
            <div>{{item.intention}}</div>
            <img v-lazy="domin+detail.user.s_userlogo" class="cover">
            <div class="center">{{detail.user.s_username}}</div>
            <div class="usershow">{{detail.user.s_usershow}}</div>
            <h1 class="center">
              LOGO <br>
              意境艺术
            </h1>
          </swiper-slide>
        </template>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        detail: {},
        swiperOption: {
          // NotNextTick is a component's own property, and if notNextTick is set to true, the component will not instantiate the swiper through NextTick, which means you can get the swiper object the first time (if you need to use the get swiper object to do what Things, then this property must be true)
          // notNextTick是一个组件自有属性，如果notNextTick设置为true，组件则不会通过NextTick来实例化swiper，也就意味着你可以在第一时间获取到swiper对象，假如你需要刚加载遍使用获取swiper对象来做什么事，那么这个属性一定要是true
          notNextTick: true,
          grabCursor: true,
          slidesPerView: 'auto',
          centeredSlides: !0,
          watchSlidesProgress: !0,
          pagination: '.swiper-pagination',
          paginationClickable: !0,
          paginationType: 'fraction',
          paginationFractionRender: (swiper, currentClassName, totalClassName) => {
            return `<span class="${currentClassName}"></span> / <span class="${totalClassName}"></span>`
          },
          mousewheelControl: true,
          observeParents: true,
          onProgress: (a) => {
            let b
            let c
            let d
            for (b = 0; b < a.slides.length; b++) {
              let es
              c = a.slides[b]
              d = c.progress
              // scale = 1 - Math.min(Math.abs(0.2 * d), 1)
              es = c.style
              es.opacity = 1 - Math.min(Math.abs(d / 2), 1)
              es.webkitTransform = es.MsTransform = es.msTransform = es.MozTransform = es.OTransform = es.transform = 'translate3d(0px,0,' + -Math.abs(150 * d) + 'px)'
            }
          },
          onSetTransition: (a, b) => {
            for (let c = 0; c < a.slides.length; c++) {
              let es
              es = a.slides[c].style
              es.webkitTransitionDuration = es.MsTransitionDuration = es.msTransitionDuration = es.MozTransitionDuration = es.OTransitionDuration = es.transitionDuration = b + 'ms'
            }
          }
        }
      }
    },
    computed: {

    },
    methods: {
      getDetail () {
        this.$http.detail({
          s_id: this.$route.params.id
        }).then(res => {
          this.detail = res.data
        }).catch(err => {
          console.error(err)
          this.$toast({
            message: '请求失败',
            iconClass: 'fa fa-times'
          })
        })
      }
    },
    mounted () {
      this.getDetail()
    }
  }
</script>

<style lang="less" scoped>

  .swiper-container {
    width: 100%;
    // height: 10rem;
    -webkit-perspective: 1200px;
    -moz-perspective: 1200px;
    -ms-perspective: 1200px;
    perspective: 1200px;
    padding-bottom: 80px;
    .backgroud{
      left: -10%;
      width: 120%;
    }
    .center{
      text-align: center;color: #fff;
      margin-top: 10px;
      &.title{
        // margin-top:1.5rem;
      }
    }
  }

  .swiper-wrapper {
    margin-top: 10px
  }

  .swiper-slide {
    width: 80%;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    -ms-transform-style: preserve-3d;
    transform-style: preserve-3d;
    padding-top: 1rem;
    img.cover{
      width: 4rem;
      height: 4rem;
      border-radius: 50%;
      display: block;
      margin: auto;
      margin-top: 1rem;
    }
    >div{
      margin-top: 10px;
      margin: 10px -5% 0
    }
    .usershow{
      padding: 10px;
      background-color: #fff;
      color: #000;
      border-radius: 5px;
      // font-size: 0.6rem;
    }
  }

  .swiper-slide .main-img {
    width: 90%;
    margin: 10px auto;
    display: block;
    // height: 7rem;
  }

  .swiper-pagination {
    color: #fff;
    position: fixed;
    // top: 0.3rem;
    bottom: 55px;
  }

  @media screen and (min-height:481px) {
    .swiper-wrapper {
      margin-top: 20px
    }
  }

  @media screen and (min-height:569px) {
    .swiper-wrapper {
      margin-top: 40px
    }
  }
</style>
